home *** CD-ROM | disk | FTP | other *** search
- #pragma once
-
- #include "Sprite.h"
-
- #ifndef NEW
- #define NEW new
- #endif
- #include <DArray.h>
-
-
- class SoundManager;
- class CSpriteGame
- {
- public:
- CSpriteGame(short imageID);
- virtual ~CSpriteGame();
-
- virtual OSErr Initialize();
-
- OSErr IntroduceExtensionIcon(GWorldPtr image,RgnHandle mask);
-
- CStaticHeap* GetSafeHeap() {return fSafeHeap;}
-
- virtual void StartGame();
- virtual void StopGame();
-
- // don't dispose of the GWorld and Rgn
- Boolean GetImage(short imageID,GWorldPtr& outGWorld,RgnHandle& outMask);
- GWorldPtr GetImage(short imageID);
- RgnHandle GetImageMask(short imageID);
-
- void PlaySound(short sndID,Boolean loopQ = false);
-
- CSpriteWorld* GetWorld() {return fWorld;}
-
- protected:
-
- enum { kHeapSize = 1024L * 1024L};
-
-
- virtual CSprite* MakeExtensionSprite(GWorldPtr image,RgnHandle mask) = 0;
- virtual void DrawBackground(const Rect& inBounds);
-
- private:
- struct Entry;
-
- OSErr PreloadGameImages();
- Entry* LocateEntryByID(short inID);
-
-
- struct Entry
- {
- short id;
- GWorldPtr gWorld;
- RgnHandle maskRgn;
- };
-
- DArray<Entry> fImageList;
- CSpriteWorld* fWorld;
- CMacHeap fMacHeap;
- CStaticHeap* fSafeHeap;
- SoundManager* fSoundManager;
- short fImageID;
- };
-
- class CGameSprite : public CPixMapSprite
- {
- public:
- CGameSprite(CSpriteWorld* world,CSpriteGame* game,long id,GWorldPtr image,
- short startTop,short startLeft,RgnHandle mask);
- virtual ~CGameSprite();
-
- CSpriteGame* GetGame() {return fGame;}
- void SetImageID(short inID);
- void PlaySound(short soundID);
-
- private:
- CSpriteGame* fGame;
- };
-
-
-